package xcmg.device.service.wechat;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import xcmg.device.dao.entity.area.HatAreaDO;
import xcmg.device.dao.entity.area.HatCityDO;
import xcmg.device.dao.entity.area.HatProvinceDO;
import xcmg.device.dao.mapper.area.HatAreaMapper;
import xcmg.device.dao.mapper.area.HatCityMapper;
import xcmg.device.dao.mapper.area.HatProvinceMapper;
import yb.ecp.fast.infra.security.CryptoUtil;

import java.math.BigInteger;
import java.util.List;

@Service
public class AreaInfoService {

    @Autowired
    private HatProvinceMapper hatProvinceMapper;
    @Autowired
    private HatCityMapper hatCityMapper;
    @Autowired
    private HatAreaMapper hatAreaMapper;

    public List<HatProvinceDO> allProvince(){
        return hatProvinceMapper.allProvince();
    }

    public List<HatCityDO> cityByProvince(String father){
        return hatCityMapper.cityByParent(father);
    }

    public List<HatAreaDO> areaByCity(String father){
        return hatAreaMapper.areaByParent(father);
    }

    public String getPwd(String userId,String pwd) throws Exception {
        String orginalText = pwd + "_" + userId;
        byte[] cypherBytes = CryptoUtil.encryptMD5(orginalText.getBytes());
        String cypherText = new BigInteger(cypherBytes).toString(16);
        return cypherText;
    }
}
